<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/salesReport.do?action=performancereport" />
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<SCRIPT language="JavaScript">
var dateElement = "";
    function openCalendar(dateValue)
    {
	    dateElement = dateValue;
  	    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	    newWindow.moveTo(550,180);
  	    newWindow.focus();
    }
	function assignDate(passedValue)
    {
	    dateElement.value=passedValue;
	    window.focus();
    }
var errors = "";
function dateRange( fileType ){

    var period="";
    var cat="";

    var d = new Date();
		var day   = d.getDate();
		var month = d.getMonth()+1;
		var year  = d.getFullYear();
		var hour  = d.getHours();
		var min   = d.getMinutes();
		var sec   = d.getSeconds();

		var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

    //alert('From Date:'+document.perfomanceReport.datefrom.value);
    //alert('To date:'+document.perfomanceReport.dateto.value);
    //alert('Product:'+document.perfomanceReport.products.value);
    //alert('Customer:'+document.perfomanceReport.customers.value);
    //added by varma(29jun2004) to validate from and to dates
    var errors = "";
    temp = document.perfomanceReport["dateto"];
    if( chkDate(document.perfomanceReport["dateto"].value,"","Y") && chkDate(temp.value,"","N") && document.perfomanceReport["dateto"].value != '' )
    {
            if( CompareDate( document.perfomanceReport["datefrom"].value, document.perfomanceReport["dateto"].value ) == false )
            {
            errors = errors + " To Date Cannot be less than From Date";
            var pa = document.getElementById("errors");
		    pa.innerHTML = errors+'<p>';
            temp.select();
            temp.focus();
            }
	}
   // till here additions of varma
    var partNumberObj = document.perfomanceReport.products;
    var processstepId = "";
    var count = 0;
    for( var i = 0; i < partNumberObj.length; i++ )
    {
        if( partNumberObj.options[i].selected )
        {
            count++;
            if ( processstepId != '' )
            {
                processstepId = processstepId + "," + partNumberObj.options[i].value;
            }
            else
            {
                processstepId = partNumberObj.options[i].value;
                if( partNumberObj.options[i].value == '0' )
                {
                    break;
                }
            }
        }
    }
    if ( processstepId == '')
    {
        processstepId = "0";
    }
    if( count > 10)
    {
        pa.innerHTML = "<li>Please select upto 10 Products only";
        return;
    }
    else
    {
        document.perfomanceReport.prompt2.value = processstepId;
    }

    if (document.perfomanceReport.datefrom.value == '' )
	    document.perfomanceReport.prompt0.value = '0';
    else
	    document.perfomanceReport.prompt0.value  = document.perfomanceReport.datefrom.value;

    if (document.perfomanceReport.dateto.value == '' )
	    document.perfomanceReport.prompt1.value = '0';
    else
    	document.perfomanceReport.prompt1.value  = document.perfomanceReport.dateto.value;

    /*if (document.perfomanceReport.products.value == '' )
    	document.perfomanceReport.prompt2.value = '0';
    else
    	document.perfomanceReport.prompt2.value  = document.perfomanceReport.products.value;*/

    if (document.perfomanceReport.customers.value == '' )
	    document.perfomanceReport.prompt3.value = '0';
    else
	    document.perfomanceReport.prompt3.value  = document.perfomanceReport.customers.value;

    document.perfomanceReport.prompt4.value = document.perfomanceReport.orderType.value;
    document.perfomanceReport.prompt5.value = "crystal";
    document.perfomanceReport.prompt6.value = defaultPrompt;

    if( fileType == 2 )
    {
        var prompt0 = document.perfomanceReport.prompt0.value;
        var prompt1 = document.perfomanceReport.prompt1.value;
        var prompt2 = document.perfomanceReport.prompt2.value;
        var prompt3 = document.perfomanceReport.prompt3.value;
        var prompt4 = document.perfomanceReport.prompt4.value;
        var prompt5 = "xlreport"; // for report type prompt
        var prompt6 = defaultPrompt; // for default prompt

        var newWindow;
        var url = '<%=chipTracContext%>/customerReport.do?action=performancexls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 ;
        newWindow = window.open ( url, 'PerformanceReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
    }
    else
    {
        document.perfomanceReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Performance/sale_performance.rpt";

        if(errors == ''){
        document.perfomanceReport.submit();
        }

    }

}
function initLoad()
{
    <%!
      String fromDate = null;
      String toDate = null;
    %>
    <%
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar = Calendar.getInstance();
        GregorianCalendar gc = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc.add(GregorianCalendar.YEAR, -1);
        Date d = gc.getTime();
        fromDate = sdf.format(d);

        SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar1 = Calendar.getInstance();
        GregorianCalendar gc1 = new GregorianCalendar(calendar1.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc1.add(GregorianCalendar.DATE, 1);
        Date d1 = gc1.getTime();
        toDate = sdf1.format(d1);
    %>
    document.getElementById("datefrom").value = "<%=fromDate%>";
    document.getElementById("dateto").value = "<%=toDate%>";
}
</script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="initLoad();">

<form name =perfomanceReport method="post">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<input type="hidden" name="prompt0">
<input type="hidden" name="prompt1">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt4">
<input type="hidden" name="prompt5">
<input type="hidden" name="prompt6">
<input type="hidden" name="prompt7">

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/sales/sales_report_menu.jsp" %>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
  <table border="0" width="90%" align=right cellspacing="4" cellpadding="2">
     <tr>
        <td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
    </tr>
    <tr><td colspan="6" align="center" class="NArialW">Performance Reports</TD></TR>
    <tr>
    	<td  colspan="6" align="left" class='NArialL'><FONT face="Verdana" size="-5" id="errors" styleClass="NArialL" color='FF0000'></FONT></td>
    </tr>
    <tr>
        <td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td>
    </tr>

    <tr>
        <td width="18%" valign="top"><font class="NArialL">Customer :</font></td>
        <td width="20%" valign="top"><font class="NArialL">
            <select size="1" name="customers" class="txfield" style="width:180px">
                <!--<option value="0">All Customers</option>-->
                <logic:iterate id="customerSelectList" name="customerSelectList">
	                <logic:notEqual name="customerSelectList" value="null">
                        <option value = <bean:write name="customerSelectList" property="value"/>>
                            <bean:write name="customerSelectList" property="label"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
            </select>
            </font>
        </td>
        <td width="5%">&nbsp;</td>
        <td width="15%" valign="top" nowrap="true" class="NArialL" ><bean:message key="label.mfgPartNumber" /> : </td>
        <td width="20%" valign="top" class="NArialL">
            <select size="5" name="products" class="txfield" multiple="true" style="width:180px">
                <option value="0" selected>All Products</option>
                <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
	                <logic:notEqual name="mktgPartNumberSelectList" value="null">
                        <option value = "<bean:write name="mktgPartNumberSelectList" property="productId"/>">
                           <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
            </select>
        </td>
        <td width="15%">&nbsp;</td>
    </tr>

    <tr>
        <td width="15%"  class="NArialL">From Date :</td>
        <td width="20%" class="NArialL">
            <input type="text" name="datefrom" size="12" class="txfield">
            <a href="javascript:openCalendar(document.perfomanceReport.datefrom)">
        <img onMouseOver="window.status='Click to Select From Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select From Date"
        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a></TD>
        <td width="5%">&nbsp;</td>
        <td width="15%" class="NArialL">To Date :</td>
        <td width="20%" class="NArialL">
            <input type="text" name="dateto" size="12" class="txfield">
            <a href="javascript:openCalendar(document.perfomanceReport.dateto)">
        <img onMouseOver="window.status='Click to Select To Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select To Date"
        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a></TD>

        <td width="15%">&nbsp;</td>
    </tr>

    <tr >
        <td width="15%">&nbsp;</td>
        <td width="20%">&nbsp;</td>
        <td width="5%" >&nbsp;</td>
        <td width="15%"><font class="NArialL">Category :</font></td>
        <td width="20%"><select name="orderType" class="txfield" style="width:180px">
            <option value="1" selected >Regular</option>
            <option value="0">Sample</option>
            <option value="2">Consignment</option>
        </select></td>
        <td width="15%"></td>
    </tr>

    <tr>
        <td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
    </tr>

    <tr>
        <td width="15%">&nbsp;</td>
        <td width="20%">&nbsp;</td>
        <td width="5%">&nbsp;</td>
        <td width="15%">&nbsp;</td>
        <td width="20%">
            <a class="NArialL" href="javascript:dateRange(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
        </td>
        <td width="15%">&nbsp;</td>
    </tr>

    <tr>
        <td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
    </tr>

    <tr>
        <td colspan=5 align=center>
            <a href="javascript:dateRange(1)"onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17"></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:document.perfomanceReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
        </td>
    </tr>
  </table>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</form>
</BODY>
</HTML>
